package com.gujiangbo.guardedsuspension;

public class GuardedSuspensionQueueTest {

    public static void main(String[] args) {
        final GuardedSuspensionQueue queue = new GuardedSuspensionQueue();
        new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                try {
                    queue.offer(Integer.valueOf(i));

                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();

        new Thread(() -> {
            try {
                while (true) {
                    System.out.println(queue.take());
                    if (queue.getSize() == 0) {
                        break;
                    }
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
    }
}
